	  var imgPath="img/";
	  var imgUrls=["01.jpg","02.jpg","03.jpg","04.jpg","05.jpg","06.jpg","07.jpg","08.jpg"];
	  var imgTitle=[["Kindle书阅读器","畅销书","Polo Ralph Lauren","超级电脑节","畅销书","个护健康","大牌鞋","厨卫下单"],
	  				["阅读新风尚","定价49折封顶","239元起","大牌PK","定价49折封顶","239元起","245起","8折起"]
	  			   ];

window.onload=function(){
	// 初始化
	var imgItems=document.getElementById("imgItems");
	var ixtItems=document.getElementById("txtItems");
	var imgs=imgItems.getElementsByTagName("img");
	console.log(imgs);
	for(var i=0;i<imgUrls.length;i++){
	   	   var nodeImg=document.createElement("img");
	   	   nodeImg.className="pic opacity0";
	   	   nodeImg.src=imgPath+imgUrls[i];
	   	   	   	   

	   	   var nodeA=document.createElement("a");
	   	   nodeA.href="#";

	   	   nodeA.appendChild(nodeImg);

	   	   var nodeLiImg=document.createElement("li");
	   	   // nodeLiImg.style.display="none";
	   	   nodeLiImg.appendChild(nodeA);
	   	   imgItems.appendChild(nodeLiImg);
	   	   nodeLiImg.no=i;

			var nodeLiTxt=document.createElement("li");
			nodeLiTxt.className="txtItemsLi";
			nodeLiTxt.title="["+imgTitle[0][i]+"]"+imgTitle[1][i]
			nodeLiTxt.no=i;
			var nodeSpan1=document.createElement("span");
           	nodeSpan1.innerHTML=imgTitle[0][i];
		   	var nodeSpan2=document.createElement("span");
           	nodeSpan2.innerHTML=imgTitle[1][i];
           	nodeLiTxt.appendChild(nodeSpan1);
          	nodeLiTxt.appendChild(nodeSpan2);
          	ixtItems.appendChild(nodeLiTxt);

	}

	function clearAllStyle(){
		for(var i=0;i<imgs.length;i++){
			imgs[i].className="pic opacity0";
			ixtItems.children[i].className="txtItemsLi";
		}
	}

	function setCurrentStyle(currentNo)
	{
		imgs[currentNo].className="pic opacity1";        
		ixtItems.children[currentNo].className="txtItemsLi currentTxt";
	}
    
    var currentNo=0;
    setCurrentStyle(currentNo);
    var t=setInterval(timer,3000);

    function timer(){
    	clearAllStyle();
    	currentNo++;
    	if(currentNo>=imgItems.children.length) currentNo=0;
    	setCurrentStyle(currentNo);
    }


	var oBtnPre=document.getElementById("arrowPre");
	oBtnPre.onclick=function(){
		currentNo--;
		if(currentNo<0){
			currentNo=imgItems.children.length-1;			
		}		 
         clearAllStyle();
         setCurrentStyle(currentNo);
	
	}

	var oBtnNext=document.getElementById("arrowNext");
	oBtnNext.onclick=function(){
		currentNo++;
		if(currentNo>=imgItems.children.length){
			currentNo=0;			
		}
      clearAllStyle();
      setCurrentStyle(currentNo);

	}

	var oContainer=document.getElementById("ShowContainer");
	oContainer.onmouseover=function(){
		clearInterval(t);
		txtItems.className="txtItems long";			

	}

	oContainer.onmouseout=function(){
		txtItems.className="txtItems short";
		t=setInterval(timer,2000);	

	}


	for(var i=0;i<txtItems.children.length;i++){
		txtItems.children[i].onmouseover=changePic;
		txtItems.children[i].onclick=changePic;
	}

    function changePic(){    	
		clearAllStyle();
		currentNo=this.no;
		setCurrentStyle(currentNo);
			
	}


}

